package belpic.spring_data.web;

import java.net.URI;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpHeaders;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.support.ServletUriComponentsBuilder;

import belpic.spring_data.domain.Application;
import belpic.spring_data.repository.ApplicationRepository;
import belpic.spring_data.repository.CrudRepositoryList;

@Controller
@RequestMapping("/applications")
public class ApplicationController extends CrudController<Application, Long>{

	@Autowired
	private ApplicationRepository repository;

	private HttpHeaders buildHeadersWithLocation(String path, Object...uriVariableValues) {
		URI uri = ServletUriComponentsBuilder.fromCurrentServletMapping().path(path).buildAndExpand(uriVariableValues).toUri();
		HttpHeaders http = new HttpHeaders();
		http.setLocation(uri);
		return http;
	}
	

	@Override
	protected Application getDomainObject() {
		return new Application();
	}
	
	protected CrudRepositoryList<Application, Long> getRepository(){
		return repository;
	}
	
}
